import aepApiRequest from '../utils/aepApiRequest';

export async function getHomeList() {
  return aepApiRequest('app/smartHome/v2/homes', {
    method: 'GET',
  });
}

export async function addHome(params: IHome) {
  return aepApiRequest('app/smartHome/homes', {
    method: 'POST',
    body: params,
  });
}


export async function addContact({
  areaCode, homeId, name, mobile
}: IPeople) {
  return aepApiRequest('app/smart_home/emergency_contacts', {
    method: 'POST',
    body: {
      areaCode,
      homeId,
      name,
      mobile,
    },
  });
}

export async function getContactList(homeId: number) {
  return aepApiRequest(`app/smart_home/emergency_contacts?homeId=${homeId}`, {
    method: 'GET',
  });
}

export async function deleteContact(ids: number[]) {
  return aepApiRequest('app/smart_home/emergency_contacts', {
    method: 'DELETE',
    body: { ids },
  });
}

export async function editContact({
  areaCode, id, name, mobile
}: IPeople) {
  return aepApiRequest('app/smart_home/emergency_contacts', {
    method: 'PUT',
    body: {
      areaCode,
      id,
      name,
      mobile,
    },
  });
}

